<?php

require_once 'Zend/Search/Lucene.php';

class IndexController extends Zend_Controller_Action {

    public function init() {
        /* Initialize action controller here */
    }

    public function indexAction() {
          
    }
    public function aboutusAction() {
          
    }
    public function contactusAction() {
             $form = new Application_Form_Contactus();
             $this->view->form = $form;
             if ($this->getRequest()->isPost()) {
                   if ($form->isValid($_POST)) {
                    $data = $form->getValues();
                    $smtpOptions = array(
                        'auth' => 'login',
                        'username' => 'zend900@gmail.com',
                        'password' => '0109404527',
                        'ssl' => 'ssl',
                        'port' => 465
                    );
                    $mailTransport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $smtpOptions);
                    $email = new Zend_Mail();
                    $email->addTo("zend900@gmail.com")  // user's email
                            ->setFrom($data['email'])
                            ->setSubject($data['subject'])
                            ->setBodyText("$data[body]
                                    from$data[email]"); // link with token or actication key
                    $email->send($mailTransport);
            }// end of if(form is valid)
        }// end of if (get request is post)
    }// end of contact us 
    public function listAction() {
        
        $product = new Application_Model_Product();
        $products = $product->getProducts(10);
        $adapter = new Zend_Paginator_Adapter_Array($products);
        $paging = new Zend_Paginator($adapter);
        $paging->setItemCountPerPage(6);
        $page = $this->_request->getParam('page', 1);
        $paging->setCurrentPageNumber($page);
        $this->view->data = $paging;
    }  

}

